<html>
<head><meta charset="utf-8"><title>changing error message · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html">changing error message</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222196945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222196945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222196945">(Jan 10 2021 at 00:24)</a>:</h4>
<p>Hello! one thing i sometimes get when working with parsers is i accidentally do <code>char == "f"</code>, it would be nice if rustc could suggest that i use <code>'f'</code> instead. I would like to try my hand at PRing this change, but i am not sure where to start and where to look to change this. Are mismatched type errors handled in a common place?</p>



<a name="222197007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197007">(Jan 10 2021 at 00:26)</a>:</h4>
<p><span class="user-mention" data-user-id="276242">@Riccardo D'Ambrosio</span> in general any part of the compiler can emit errors; I would start by grepping for the error code or format string</p>



<a name="222197020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197020">(Jan 10 2021 at 00:27)</a>:</h4>
<p>Yeah that was what i was going to do but i was just wondering if those errors are handled in a common place instead of anywhere in typeck</p>



<a name="222197027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197027">(Jan 10 2021 at 00:27)</a>:</h4>
<p>Besides, <code>1,064 code results in rust-lang/rust</code> <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="222197142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197142">(Jan 10 2021 at 00:30)</a>:</h4>
<p>Well for one you only want to be searching in <code>compiler/</code>. That gives:</p>
<div class="codehilite" data-code-language="Bash Session"><pre><span></span><code><span class="gp">$</span> rg E0308 compiler/
<span class="go">compiler/rustc_error_codes/src/error_codes.rs</span>
<span class="go">157:E0308: include_str!("./error_codes/E0308.md"),</span>

<span class="go">compiler/rustc_error_codes/src/error_codes/E0308.md</span>
<span class="go">5:```compile_fail,E0308</span>

<span class="go">compiler/rustc_typeck/src/check/pat.rs</span>
<span class="go">56:    /// error[E0308]: mismatched types</span>
<span class="go">70:    /// error[E0308]: mismatched types</span>

<span class="go">compiler/rustc_infer/src/infer/error_reporting/mod.rs</span>
<span class="go">1516:                    // error[E0308]: mismatched types</span>
<span class="go">1894:                struct_span_err!(self.tcx.sess, span, E0308, "{}", failure_str)</span>

<span class="go">compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs</span>
<span class="go">184:    // error[E0308]: implementation of `Foo` does not apply to enough lifetimes</span>
</code></pre></div>



<a name="222197144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197144">(Jan 10 2021 at 00:30)</a>:</h4>
<p>haha i was just doing that</p>



<a name="222197145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197145">(Jan 10 2021 at 00:30)</a>:</h4>
<p>So the error is reported in <code>compiler/rustc_infer/src/infer/error_reporting/mod.rs</code>.</p>



<a name="222197146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197146">(Jan 10 2021 at 00:30)</a>:</h4>
<p>thank you</p>



<a name="222197147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197147">(Jan 10 2021 at 00:30)</a>:</h4>
<p>However that brings together tons of different cases.</p>



<a name="222197153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197153">(Jan 10 2021 at 00:30)</a>:</h4>
<p>So that's not the spot that needs to be changed <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="222197156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197156">(Jan 10 2021 at 00:31)</a>:</h4>
<p>you're right, but i don't think that matters as long as i can tell if the type originated from a literal, right? can you even do that? <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="222197172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197172">(Jan 10 2021 at 00:31)</a>:</h4>
<p>I'm not that knowledgeable about typeck, but I'm guessing there is a (possibly hacky) way.</p>



<a name="222197173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197173">(Jan 10 2021 at 00:31)</a>:</h4>
<p>Not from the type, but you may be able to get it from the HIR node</p>



<a name="222197178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197178">(Jan 10 2021 at 00:31)</a>:</h4>
<p>It depends what the scope of your change is.</p>



<a name="222197228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197228">(Jan 10 2021 at 00:32)</a>:</h4>
<p>I feel its fine to generalize the change, if someone feeds <code>foo("f")</code> it should be caught too</p>



<a name="222197229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197229">(Jan 10 2021 at 00:32)</a>:</h4>
<p>Do you want to suggest just for <code>==</code> or for anything where it expected a <code>String</code>/<code>str</code> and found a <code>char</code>? (I'm guessing the latter.)</p>



<a name="222197232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197232">(Jan 10 2021 at 00:32)</a>:</h4>
<p>yup the latter</p>



<a name="222197246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197246">(Jan 10 2021 at 00:32)</a>:</h4>
<p>ill take a look at where the stuff is emitted and if i can get a node from that <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="222197273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197273">(Jan 10 2021 at 00:33)</a>:</h4>
<p>I'm not sure where in <code>rustc_typeck</code> it should be changed – there's a lot of places that emit "mismatched types". I'm guessing <code>rustc_typeck::check</code>, but that doesn't narrow it down much. I would ask in <a class="stream" data-stream-id="147480" href="/#narrow/stream/147480-t-compiler.2Fwg-diagnostics">#t-compiler/wg-diagnostics</a> – they may know.</p>



<a name="222197278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197278">(Jan 10 2021 at 00:33)</a>:</h4>
<p>alright, thanks! <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="222197280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197280">(Jan 10 2021 at 00:33)</a>:</h4>
<p>Or someone more knowledgeable might come by here.</p>



<a name="222197282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197282">(Jan 10 2021 at 00:33)</a>:</h4>
<p>But can't hurt to ask there too :)</p>



<a name="222197288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197288">(Jan 10 2021 at 00:33)</a>:</h4>
<p>You're welcome :)</p>



<a name="222197514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197514">(Jan 10 2021 at 00:39)</a>:</h4>
<p>Ah it seems the place im looking for is <code>rustc_typeck/src/ty/errors.rs</code></p>



<a name="222197517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197517">(Jan 10 2021 at 00:39)</a>:</h4>
<p>sorry, <code>rustc_middle</code></p>



<a name="222197522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197522">(Jan 10 2021 at 00:39)</a>:</h4>
<p>You mean <code>/error.rs</code>? (You said <code>errors.rs</code>)</p>



<a name="222197563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197563">(Jan 10 2021 at 00:40)</a>:</h4>
<p>yeah haha</p>



<a name="222197575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197575">(Jan 10 2021 at 00:40)</a>:</h4>
<p>although i am not quite sure which variant this is, because typeerror has multiple variants</p>



<a name="222197588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197588">(Jan 10 2021 at 00:41)</a>:</h4>
<p>I think <code>TypeError::Mismatch</code></p>



<a name="222197590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197590">(Jan 10 2021 at 00:41)</a>:</h4>
<p><code>ProjectionMismatched</code> is the one with the correct error message im looking for</p>



<a name="222197591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197591">(Jan 10 2021 at 00:41)</a>:</h4>
<p>mismatched is just <code>write!(f, "types differ"),</code></p>



<a name="222197592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197592">(Jan 10 2021 at 00:41)</a>:</h4>
<p>Ah I didn't see that one.</p>



<a name="222197639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197639">(Jan 10 2021 at 00:42)</a>:</h4>
<p>So i think thats where i need to do things, just need to find out what some of these things are, RA is showing them as unknown <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="222197642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197642">(Jan 10 2021 at 00:42)</a>:</h4>
<p>What things is it showing as unknown?</p>



<a name="222197646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197646">(Jan 10 2021 at 00:42)</a>:</h4>
<p>values, which seems to be the important bit</p>



<a name="222197647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197647">(Jan 10 2021 at 00:42)</a>:</h4>
<p>E.g.?</p>



<a name="222197654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197654">(Jan 10 2021 at 00:42)</a>:</h4>
<p>By the way, the rustc API docs are your friend: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/">https://doc.rust-lang.org/nightly/nightly-rustc/</a></p>
<p>I look at them <em>constantly</em></p>



<a name="222197657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197657">(Jan 10 2021 at 00:43)</a>:</h4>
<p>Oh it seems values is an <code>ExpectedFound&lt;DefId&gt;</code>, which just gives me <code>expected: DefId</code> and <code>found: DefId</code></p>



<a name="222197659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197659">(Jan 10 2021 at 00:43)</a>:</h4>
<p>is it surprising that the logic isn't in <code>rustc_error{,codes}s</code>?</p>



<a name="222197660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197660">(Jan 10 2021 at 00:43)</a>:</h4>
<p>yeah lol</p>



<a name="222197663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197663">(Jan 10 2021 at 00:43)</a>:</h4>
<p><code>rustc_errors</code> is generic over all kinds of errors.</p>



<a name="222197699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197699">(Jan 10 2021 at 00:44)</a>:</h4>
<p>It would be weird to have type error logic in it.</p>



<a name="222197701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197701">(Jan 10 2021 at 00:44)</a>:</h4>
<p>good point</p>



<a name="222197703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197703">(Jan 10 2021 at 00:44)</a>:</h4>
<p>But yeah I personally think it would be better if error reporting logic were more separated.</p>



<a name="222197706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197706">(Jan 10 2021 at 00:44)</a>:</h4>
<p>ok so i have def ids which represent... something, i can probably get some thing from tcx, but that would be the types, and i wouldnt know the node, right?</p>



<a name="222197773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197773">(Jan 10 2021 at 00:47)</a>:</h4>
<p>I'm still a little bit confused on what DefIds are since they seem to be used for pretty much everything</p>



<a name="222197895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197895">(Jan 10 2021 at 00:51)</a>:</h4>
<p><span class="user-mention" data-user-id="276242">@Riccardo D'Ambrosio</span> <a href="https://rustc-dev-guide.rust-lang.org/identifiers.html?highlight=defid#in-the-hir">https://rustc-dev-guide.rust-lang.org/identifiers.html?highlight=defid#in-the-hir</a></p>



<a name="222197902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197902">(Jan 10 2021 at 00:52)</a>:</h4>
<p>Thanks</p>



<a name="222197956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222197956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222197956">(Jan 10 2021 at 00:52)</a>:</h4>
<p>Hmm this change doesnt seem simple because TypeError just has the message for the label, not the whole diagnostic, so applying extra info to the diagnostic isnt doable from there</p>



<a name="222198335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198335">(Jan 10 2021 at 01:04)</a>:</h4>
<p>I don't think <code>DefId</code>s are going to help you here – you probably need to use <code>NodeId</code></p>



<a name="222198345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198345">(Jan 10 2021 at 01:04)</a>:</h4>
<p>huh, I didn't realize NodeIds were a thing</p>



<a name="222198349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198349">(Jan 10 2021 at 01:05)</a>:</h4>
<p>anyway, that's not how you look up Nodes, you need a HirId for that</p>



<a name="222198353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198353">(Jan 10 2021 at 01:05)</a>:</h4>
<p>Ah, good point.</p>



<a name="222198361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198361">(Jan 10 2021 at 01:05)</a>:</h4>
<p>I think <code>NodeId</code>s are just for the AST.</p>



<a name="222198371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198371">(Jan 10 2021 at 01:05)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> The section of the dev guide you sent mentions <code>NodeId</code> <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> </p>
<blockquote>
<p>A DefId, as the name suggests, identifies a particular definition, or top-level item, in a given crate. It is composed of two parts: a CrateNum which identifies the crate the definition comes from, and a DefIndex which identifies the definition within the crate. Unlike NodeIds, there isn't a DefId for every expression, which makes them more stable across compilations.</p>
</blockquote>
<p>Should it be updated to point to <code>HirId</code>? (I can do the change.)</p>



<a name="222198415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198415">(Jan 10 2021 at 01:06)</a>:</h4>
<p>hmm, I think so?</p>



<a name="222198417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198417">(Jan 10 2021 at 01:06)</a>:</h4>
<p>I'm unclear what NodeIds actually are</p>



<a name="222198443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198443">(Jan 10 2021 at 01:07)</a>:</h4>
<p>Same here <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> I'm guessing they're the equivalent of <code>HirId</code> but for <code>rustc_ast</code>?</p>



<a name="222198445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198445">(Jan 10 2021 at 01:07)</a>:</h4>
<p>Maybe we can get <span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> to take a look.</p>



<a name="222198486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198486">(Jan 10 2021 at 01:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125294">Aaron Hill</span> may have more time</p>



<a name="222198487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198487">(Jan 10 2021 at 01:08)</a>:</h4>
<p>The dev guide talks about them one section up <span aria-label="embarrassed" class="emoji emoji-1f633" role="img" title="embarrassed">:embarrassed:</span> </p>
<p><a href="https://rustc-dev-guide.rust-lang.org/identifiers.html#in-the-ast">https://rustc-dev-guide.rust-lang.org/identifiers.html#in-the-ast</a></p>
<blockquote>
<p>A NodeId is an identifier number that uniquely identifies an AST node within a crate. Every node in the AST has its own NodeId, including top-level items such as structs, but also individual statements and expressions.</p>
<p>However, because they are absolute within a crate, adding or removing a single node in the AST causes all the subsequent NodeIds to change. This renders NodeIds pretty much useless for incremental compilation, where you want as few things as possible to change.</p>
<p>NodeIds are used in all the rustc bits that operate directly on the AST, like macro expansion and name resolution.</p>
</blockquote>



<a name="222198569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198569">(Jan 10 2021 at 01:11)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/rustc-dev-guide/issues/1015">rustc-dev-guide#1015</a>.</p>



<a name="222198723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198723">(Jan 10 2021 at 01:16)</a>:</h4>
<p>NodeId essentially exists to bridge between AST-based name resolution and AST-&gt;HIR lowering. Once HIR is constructed (ie as soon as one has access to a TyCtxt), all one needs to care about are HirIds (and DefIds for higher-level stuff).</p>



<a name="222198800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198800">(Jan 10 2021 at 01:17)</a>:</h4>
<p>By the way, can <code>HirId</code>s refer to definitions?</p>



<a name="222198840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198840">(Jan 10 2021 at 01:18)</a>:</h4>
<p>(I.e. is <code>HirId</code> a superset of <code>DefId</code>.)</p>



<a name="222198876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198876">(Jan 10 2021 at 01:19)</a>:</h4>
<p>HirIds can definitely refer to definitions. I'm unclear if there are definitions that can't be referred to by HirIds</p>



<a name="222198944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198944">(Jan 10 2021 at 01:20)</a>:</h4>
<p>HirId are a LocalDefId + an ItemLocalId. The conversion between HirId and DefId is done using two hash maps.</p>



<a name="222198946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198946">(Jan 10 2021 at 01:20)</a>:</h4>
<p><code>local_def_id_to_hid_id</code> and <code>local_def_id</code>.</p>



<a name="222198958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198958">(Jan 10 2021 at 01:21)</a>:</h4>
<p>Huh, so theoretically you can create a <code>DefId</code> that is actually an expression?</p>



<a name="222198974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222198974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222198974">(Jan 10 2021 at 01:22)</a>:</h4>
<p>I think that will panic</p>



<a name="222199012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199012">(Jan 10 2021 at 01:22)</a>:</h4>
<p>Well maybe it will panic when you use it, but you can construct it.</p>



<a name="222199014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199014">(Jan 10 2021 at 01:22)</a>:</h4>
<p>no, I think constructing it will panic</p>



<a name="222199019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199019">(Jan 10 2021 at 01:22)</a>:</h4>
<p>Then how can you use <code>local_def_id</code>?</p>



<a name="222199021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199021">(Jan 10 2021 at 01:22)</a>:</h4>
<p>All HIR nodes have HirIds. DefIds are sparser: Items, lifetimes, generic parameters, and a few others.</p>



<a name="222199033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199033">(Jan 10 2021 at 01:23)</a>:</h4>
<p>Oh... you mean that <code>local_def_id</code> will only work if the <code>HirId</code> belongs to a definition?</p>



<a name="222199046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199046">(Jan 10 2021 at 01:23)</a>:</h4>
<p>Ah, I think you're right <span class="user-mention" data-user-id="232545">@Joshua Nelson</span>: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/definitions/struct.Definitions.html#structfield.hir_id_to_def_id">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/definitions/struct.Definitions.html#structfield.hir_id_to_def_id</a></p>



<a name="222199097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199097">(Jan 10 2021 at 01:24)</a>:</h4>
<p>For diagnostic purposes, the framework has been conceived for thin-grained messages. <code>HirId</code> are meant for this.</p>



<a name="222199172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199172">(Jan 10 2021 at 01:26)</a>:</h4>
<p><code>DefId</code> are the most highest-level stuff, involved in codegen. This is very restrictive, and on purpose.</p>



<a name="222199178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199178">(Jan 10 2021 at 01:26)</a>:</h4>
<p>For instance, all the lint levels are defined per-HirId.</p>



<a name="222199791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222199791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222199791">(Jan 10 2021 at 01:45)</a>:</h4>
<p>Opened a PR to document <code>NodeId</code>: <a href="https://github.com/rust-lang/rust/issues/80860">#80860</a></p>



<a name="222214946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/changing%20error%20message/near/222214946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/changing.20error.20message.html#222214946">(Jan 10 2021 at 09:53)</a>:</h4>
<blockquote>
<p>HirIds can definitely refer to definitions. I'm unclear if there are definitions that can't be referred to by HirIds</p>
</blockquote>
<p>FWIW, non-local definitions don't have <code>HirId</code>s since the HIR is local. But IIRC converting from <code>LocalDefId</code> into<code>HirId</code> is infallible</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>